package com.biz.primus.ms.product.trans;

import com.biz.primus.base.vo.commodity.ProductListItemVo;
import com.biz.primus.base.vo.commodity.ProductPromotionVo;
import com.biz.primus.ms.product.interfaces.ProductPrototype;

import java.util.function.Function;

/**
 * User: jiangnan
 * Description:
 */
public class ProductPrototype2ProductListItemVo implements Function<ProductPrototype,ProductListItemVo> {
    @Override
    public ProductListItemVo apply(ProductPrototype productPrototype) {
        if (productPrototype== null){
            return null;
        }

        ProductListItemVo respVo = new ProductListItemVo();
        respVo.setBase(productPrototype.getProductBaseVo());
        respVo.setProductPriceVo(productPrototype.getProductPriceVo());
        ProductPromotionVo productPromotionVo = new ProductPromotionVo();
        productPromotionVo.setProductPromotionTag(productPrototype.getProductPromotionTagRespVo());
        productPromotionVo.setSpecialOfferPromotion(productPrototype.getProductSpecialOfferPromotion());
        respVo.setProductPromotionVo(productPromotionVo);
        respVo.setProductStockVo(productPrototype.getProductStockVo());
        respVo.setPredictTime(productPrototype.getPredictTime());
        respVo.setProductFinalPriceVo(productPrototype.getProductFinalPriceVo());
        return respVo;
    }
}
